package com.home.admin.base;

import com.home.base.core.framework.msg.ServerResponse;
import com.home.common.annotation.CheckApiClient;
import com.home.common.constants.client.ClientConstant;
import com.home.common.framework.core.controller.BaseController;
import com.home.common.model.TreeNode;
import com.home.security.browser.shiro.ShiroUtils;
import com.home.common.model.CurrentUser;
import com.home.webapp.base.entity.BaseRoleMenu;
import com.home.webapp.base.service.BaseRoleMenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * Description: 菜单角色 controller
 * Created by 王大宸 on 2020-10-05 23:28:38
 * Created with IntelliJ IDEA.
 */
@Controller
@RequestMapping(value = "/base/role/menu")
@CheckApiClient(title = "菜单角色", clientId = ClientConstant.CLIENT_WEB)
public class BaseRoleMenuController extends BaseController<BaseRoleMenuService, BaseRoleMenu, String> {
    private static final Logger logger = LoggerFactory.getLogger(BaseRoleMenuController.class);

    /***
     * 功能说明：获取菜单树
     *
     * @author 王大宸
     * @date 2020/10/7 17:54
     * @param roleId  角色id
     * @return com.home.common.framework.msg.ServerResponse<java.util.List < java.util.Map < java.lang.String, java.lang.Object>>>
     */
    @GetMapping(value = "/zTree/{roleId}")
    @ResponseBody
    public ServerResponse<List<TreeNode>> menuTree(@PathVariable("roleId") String roleId) {
        CurrentUser userInfo = ShiroUtils.getUserInfo();
        return baseService.menuTree(roleId, userInfo);
    }

}